[% setvar title Make length(@array) work %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p>Make length(@array) work</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: Nathan Torkington &lt;<a href='mailto:gnat@frii.com'>gnat@frii.com</a>&gt;
  Date: 12 Sep 2000
  Last Modified: 15 Sep 2000
  Mailing List: <a href='mailto:perl6-language-subs@perl.org'>perl6-language-subs@perl.org</a>
  Number: 212
  Version: 2
  Status: Retired</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>length(@foo) should return the number of elements in
@foo.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>Presently length() has a prototype of ($) which means it coerces its
argument into scalar context.  Many newbies think of the number of
elements in an array as its &quot;length&quot;, and try to use this function.
Instead of the size of the array, they get a rough base-10 logarityhm
of the number of elements.</p>
<p>I propose to make length() return the number of elements in the array
it is passed, if its first argument begins with @.</p>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>The optimizer could replace</p>
<pre>  length @array</pre>
<p>with</p>
<pre>  scalar(@array)</pre>
<p>The perl526 converter could replace</p>
<pre>  length @array</pre>
<p>with</p>
<pre>  length scalar(@array)</pre>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<p>perlfunc for documentation on length() function</p>
</div>
